package com.bobo.controller.user;

import com.bobo.annotations.Prm;
import com.bobo.annotations.RequestMapping;
import com.bobo.annotations.RequestMethod;
import com.bobo.controller.base.BaseServlet;
import com.bobo.model.Tag;
import com.bobo.model.User;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by bobo on 16-11-7.
 */
@WebServlet(name = "user",urlPatterns = {"/user/*"})
public class UserController extends BaseServlet {

    @RequestMapping("/add")
    public String add(HttpServletRequest request){
        return "user";
    }


    @RequestMapping(value = "/add",method = RequestMethod.POST)
        public String create(@Prm("user")User user ){
        System.out.println(user.toString()+user.getPerson().getId());
        List<Tag> tags = user.getTags();
        for(Tag tag:tags){
            System.out.println(tag.getId()+"++++++++");
        }
        System.out.println(user.getPhoto().getImg());
        return "redirect:/";
    }



    ///admin/user/1/get
    @RequestMapping(value = "/get",method = RequestMethod.POST)
    public String get( @Prm("id")Integer id,  @Prm("pwd")String pwd, @Prm("value") String name){
        System.out.println(id+pwd+name);
        return "redirect:/";
    }

    @RequestMapping("/get")
    public String get( @Prm("id")Integer id){
        System.out.println(id);
        return "user";
    }
}
